package com.saturn.titan.util;

public class SiteUtil {
	
	public static String generateSiteID(int siteIDNumber, String type){
		String siteID = "";
		StringBuffer stringBuffer = new StringBuffer();
		stringBuffer.append(type);
		try {
			siteIDNumber = siteIDNumber + 1;
			for(int i=1; i<= 5 - (siteIDNumber+"").length();i++) {
				stringBuffer.append("0");
			}
			stringBuffer.append(siteIDNumber);
		} catch (NumberFormatException e) {
			return "DATAERROR#获取最大唯一标识[" + siteIDNumber + "]错误，请重试";
		}
		siteID = stringBuffer.toString();
		return siteID;
	}
	
	public static String convertSiteTypeToSiteIDPrefix(String type) {
		if(type.equals("forum")){
			return "FM";
		} else if(type.equals("homeNews")) {
			return "HN";
		} else if(type.equals("foreignNews")) {
			return "FN";
		} else if(type.equals("blog")) {
			return "BG";
		} else if(type.equals("microBlog")) {
			return "MB";
		} else if(type.equals("metaSearcher")) {
			return "MS";
		} else if(type.equals("video")) {
			return "VD";
		}
		return "ERROR";
	}


}
